define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'clothmaking_boiler_plc/index' + location.search,
                    add_url: 'clothmaking_boiler_plc/add',
                    edit_url: 'clothmaking_boiler_plc/edit',
                    del_url: 'clothmaking_boiler_plc/del',
                    multi_url: 'clothmaking_boiler_plc/multi',
                    import_url: 'clothmaking_boiler_plc/import',
                    table: 'clothmaking_boiler_plc',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'boiler.alias', title: __('Boiler_id')},
                        {field: 'flow', title: __('Flow'), operate:'BETWEEN'},
                        {field: 'SpeedStirringSpeed', title: __('Speedstirringspeed'), operate:'BETWEEN'},
                        {field: 'SpeedPV', title: __('Speedpv'), operate:'BETWEEN'},
                        {field: 'Weight', title: __('Weight'), operate:'BETWEEN'},
                        {field: 'FrontPressure', title: __('Frontpressure'), operate:'BETWEEN'},
                        {field: 'BackPressure', title: __('Backpressure'), operate:'BETWEEN'},
                        {field: 'ValveBackPressure', title: __('Valvebackpressure'), operate:'BETWEEN'},
                        {field: 'BackFlow', title: __('Backflow'), operate:'BETWEEN'},
                        {field: 'Temperature', title: __('Temperature'), operate:'BETWEEN'},
                        {field: 'InletTemperature', title: __('Inlettemperature'), operate:'BETWEEN'},
                        {field: 'OutletTemperature', title: __('Outlettemperature'), operate:'BETWEEN'},
                        {field: 'Pressure', title: __('Pressure'), operate:'BETWEEN'},
                        {field: 'barometricPressure', title: __('Barometricpressure'), operate:'BETWEEN'},
                        {field: 'humidity', title: __('Humidity'), operate:'BETWEEN'},
                        {field: 'CirculationPressure', title: __('Circulationpressure'), operate:'BETWEEN'},
                        {field: 'LiquidLevel', title: __('Liquidlevel'), operate:'BETWEEN'},
                        {field: 'circulatingPumpSpeed', title: __('Circulatingpumpspeed'), operate:'BETWEEN'},
                        {field: 'circulatingValveOpening', title: __('Circulatingvalveopening'), operate:'BETWEEN'},
                        {field: 'InletPressure', title: __('Inletpressure'), operate:'BETWEEN'},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'plcrecordid', title: __('Plcrecordid')},
                        {field: 'blendingSpeed', title: __('Blendingspeed'), operate:'BETWEEN'},
                        {field: 'mass', title: __('Mass'), operate:'BETWEEN'},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
